<template>
  <el-dialog v-model="updateDialog" title="更新" width="800">
    <el-form >
      <el-form-item label="角色名" label-width="80">
        <el-input autocomplete="off" v-model="RowData.roleName" />
      </el-form-item>
      <el-form-item label="角色描述" label-width="80">
        <el-input autocomplete="off" v-model="RowData.roleDesc" />
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="updateDialog = false">关闭</el-button>
        <el-button @click="save" type="primary">保存</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup>
import {defineModel} from "@vue/runtime-core";

import axios from '../../axios/index.js'
import {ElMessage} from "element-plus";

let updateDialog = defineModel('updateDialog')
const emit = defineEmits(['loadData'])
const RowData = defineModel('row')

//保存用户
function save() {
  axios.put('/role/update', null, {params: {
      id: RowData.value.id,
      roleName: RowData.value.roleName,
      roleDesc: RowData.value.roleDesc
    }}).then(resp=>{
    ElMessage({
      message: resp.data.message,
      type: 'success',
      duration: 1500,
      onClose: function(){
        updateDialog.value = false
        emit('loadData')
      }
    })
  })
}
</script>

<style scoped>

</style>